package com.hf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hf.entity.Roles;
import com.hf.entity.RolesParam;
import com.hf.mapper.RolesMapper;
import com.hf.service.IRolesService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author eight
 * @since 2021-06-06
 */
@Service
public class RolesServiceImpl extends ServiceImpl<RolesMapper, Roles> implements IRolesService {

	@Autowired
	RolesMapper rolesMapper;

	@Override
	public IPage<Roles> getList(RolesParam r) {

		Page<Roles> p = new Page<>();

		QueryWrapper<Roles> q = new QueryWrapper<>();

		if (r.getRoleName() != null && !r.getRoleName().equals("")) {

			q.like("role_name", r.getRoleName());
		}
		q.orderByDesc("id");

		return rolesMapper.selectPage(p, q);
	}
}
